# _*_ coding:utf-8 _*_
# 开发人员：zhu
# 项目名称：owner
# 开发时间：2022/2/2818:35
# 开发工具：PyCharm
import sys
from PyQt5 import QtWidgets, QtGui, QtCore
from PyQt5.QtCore import QEventLoop, QTimer

import newsse
from untitled import Ui_DATA_OWNER
from newsse import *

# 重定向信号
class EmittingStr(QtCore.QObject):
        textWritten = QtCore.pyqtSignal(str)  # 定义一个发送str的信号

        def write(self, text):
            self.textWritten.emit(str(text))
            loop = QEventLoop()
            QTimer.singleShot(1000, loop.quit)
            loop.exec_()

class MyPyQT_Form(QtWidgets.QWidget, Ui_DATA_OWNER):
    def __init__(self):
        super(MyPyQT_Form, self).__init__()
        self.setupUi(self)

    def outputWritten(self, text):
        # self.textEdit.clear()
        cursor = self.textEdit.textCursor()
        cursor.movePosition(QtGui.QTextCursor.End)
        cursor.insertText(text)
        self.textEdit.setTextCursor(cursor)
        self.textEdit.ensureCursorVisible()


    # 实现pushButton_click()函数，textEdit是我们放上去的文本框的id
    def pushButton_click(self):
        # self.textEdit.setText("你点击了按钮")

        # self.textBroswer.setText("nihao")
        self.textBrowser.setText('数据初始化成功！关键字如下：')

    def pushclick2(selt):
        selt.textBrowser_2.setText('构建安全索引【T】成功：')
        selt.textBrowser_4.setText('构建安全索引【A】成功：')

    # def pushclick3(selt):
    def pushclick4(selt):
        selt.textBrowser_3.setText('安全索引上链成功')


if __name__ == '__main__':
    # print(str(newsse.intialization()))
    # newsse.main()
    T, A, worddict = newsse.main()
    app = QtWidgets.QApplication(sys.argv)
    my_pyqt_form = MyPyQT_Form()
    my_pyqt_form.show()
    sys.exit(app.exec_())
